
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);

const routes = [
	{
		path: '/login',
		name: 'login',
		component: () => import('../views/login/login'),
		meta: {
			title: '登录',
			requireAuth: false, //不做拦截处理
			selectEdit: false,
			keepAlive: false,
		}
	},
	{
		path: '/',
		component: () => import('../components/layout/layout'),
		name: 'layout',
		meta: {
			title: 'layout',
			requireAuth: true,
			selectEdit: false,
			keepAlive: true,
		},
		redirect: '/index',

		children: [{
				path: '/index',
				component: () => import('../views/index/index'),
				name: 'index',
				meta: {
					title: '首页',
					requireAuth: true,
					selectEdit: false,
					keepAlive: true,
				}
			},{
				path: '/demo1',
				component: () => import('../views/demo1/demo1'),
				name: 'demo1',
				meta: {
					title: 'demo1',
					requireAuth: true,
					selectEdit: false,
					keepAlive: true,
				}

			},{
				path: '/demo2',
				component: () => import('../views/demo2/demo2'),
				name: 'demo2',
				meta: {
					title: 'demo2',
					requireAuth: true,
					selectEdit: false,
					keepAlive: true,
				}

			},{
				path: '/demo3',
				component: () => import('../views/demo3/demo3'),
				name: 'demo3',
				meta: {
					title: 'demo3',
					requireAuth: true,
					selectEdit: false,
					keepAlive: true,
				}

			}

		]
	},
	
];

//路由重复,捕获异常
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
};
const router = new VueRouter({
	// mode: "history",
	base: process.env.BASE_URL,
	routes
});

export default router;